import java.util.*;

public class LearnSet{
	public static void main(String[] args){
		System.out.println("hello world.");
		// 1、定义
		Set<String> mySet = new HashSet<String>();
		mySet.add("bana");
		mySet.add("waterlamen");
		mySet.add("apple");
		
		// 2、迭代
		System.out.println("迭代======================");
		for(String item : mySet){
			System.out.print(item + "->");
		}
		System.out.println();
		System.out.println();
		System.out.println("iterator 迭代，并且移除==========");
		
		Iterator<String> iterator = mySet.iterator();
		while(iterator.hasNext()){
			if(iterator.next().equals("apple")){
				// 重点
				iterator.remove();
			}
		}
		
		System.out.println();
		System.out.println();
		System.out.println("size =====================");
		System.out.println("size = " + mySet.size());
		
		System.out.println();
		System.out.println();
		System.out.println("remove =====================");
		mySet.remove("waterlamen");
		
		
		System.out.println();
		System.out.println();
		System.out.println("print =====================");
		mySet.forEach(System.out::print);
		System.out.println(mySet);
		System.out.println();
	}
}